<%- content_for :head do -%>
  <script type="text/javascript" charset="utf-8">
	putofactureForm = new Subform('<%= escape_javascript(render(:partial => "putofacture", :object => Putofacture.new, :locals => {:index => "INDEX"})) %>',<%= @pulve.putofactures.length %>,'putofactures');
	putoparcelleForm = new Subform('<%= escape_javascript(render(:partial => "putoparcelle", :object => Putoparcelle.new, :locals => {:index => "INDEX"})) %>',<%= @pulve.putoparcelles.length %>,'putoparcelles');
  </script>
<%- end -%>

<p>
  <%= link_to_function "Show/Hide Params", visual_effect(:toggle_blind, :params, :duration => "0.1") %>
</p>
<div id="params" style="display:none;">
  <%= debug params %>
</div>

<%= render :partial => "error_messages", :object => @pulve, :locals => {:order => [:name, :putoparcelles, :all]} %>

<% form_for @pulve do |f| -%>

<fieldset>
  <legend>Traitement</legend>
	<table>
	<tr>
		<td>Nom : </td>
		<td><%= f.text_field :name, :size => 10 %></td>
	</tr>
	<tr>
		<td>Prestataire</td>
		<td><%= select("pulve", "user_id", User.find(:all).collect{ |c| [ c.name, c.id] }) %></td>
	</tr>
	<tr>
		<td>Prix du passage</td>
		<td><%= f.text_field :cout_ha_passage, :size => 3 %> euros/Ha</td>
	</tr>
	</table>
</fieldset>

<fieldset>
  <legend>Produit</legend>
	<table>
	<tr>
		<td>Categorie: </td>
		<td><%= select("pulve", "category_id", Category.find_by_type("traitement").collect{ |c| [ c.name, c.id] }) %></td>
	</tr>
	<tr>
		<td>prix du littre: </td>
		<td><%= f.text_field :prix_littre, :size => 3 %> euros/L</td>
	</tr>
	<tr>
		<td>Dosage: </td>
		<td><%= f.text_field :dosage, :size => 3 %> L/Ha</td>
	</tr>
	</table>
</fieldset>
<%#pulve ok %>
<fieldset>
  <legend><%= @pulve.putoparcelles.length %> Pacelles</legend>
	<div id="putoparcelles">
    <%= render :partial => 'putoparcelle', :collection => @pulve.putoparcelles %>
  </div>
  <p><%= link_to_function "Ajouter une Parcelle", "putoparcelleForm.add()" %></p>
</fieldset>

<fieldset>		
  <legend>Factures</legend>		
  <div class="yui-g">		
    <div class="yui-u first">		
      <div id="putofactures">		
        <%= render :partial => 'putofacture', :collection => @pulve.putofactures %>		
      </div>		
      <p><%= link_to_function "Ajouter une Facture", "putofactureForm.add()" %></p>		
    </div>		
  </div>		
</fieldset>

<p>
<%= f.submit "Submit" %>
</p>
<% end -%>
